<?php
require_once("../../controllers/init.php");
//echo "Filesystem root = ".$FILE_SYSTEM_ROOT."\n<br>";
require_once($FILE_SYSTEM_ROOT."/controllers/authentication.php");
//echo "logged on - ".(($IS_LOGGED_ON)?"true\n":"false\n");
require_once($FILE_SYSTEM_ROOT."/model/classes/events/BookingForm.php");


if (!isset($_POST['raptor-content'])) {
echo 'No content to save';
return;
}
 
// Decode content
$postedContent = json_decode($_POST['raptor-content']);
 
// Validate content
if (!$postedContent) 
{
	if (json_last_error() !== JSON_ERROR_NONE) 
	{
		echo 'Error reading content, please try again';
		return;
	}
	echo 'No content to save';
}
 
// Save content
foreach ($postedContent as $id => $html) 
{
	// Store content in your persistent data store
/*	echo "Saved content ID #{$id}\n";
	echo "$html\n";*/
	
	$params = explode('-',$id);
	$EventID = $params[0];
	$TabID = $params[1];
		
	$bookingForm = new BookingForm($EventID);
	switch($TabID)
	{
		case 1:
			$bookingForm->setGeneralHTML($html);
			break;
			
		case 2:
			$bookingForm->setVergersHTML($html);
			break;
			
		case 3:
			$bookingForm->setMusicHTML($html);
			break;
			
		case 4:
			$bookingForm->setFinanceHTML($html);
			break;
			
		case 5:
			$bookingForm->setCateringHTML($html);
			break;
			
		case 6:
			$bookingForm->setPublicityHTML($html);
			break;
			
		case 7:
			$bookingForm->setTimetableHTML($html);
			break;
			
		case 8:
			$bookingForm->setSafeguardingHTML($html);
			break;
			
		case 9:
			$bookingForm->setLiturgyHTML($html);
			break;
			
	}
	
	echo $bookingForm->getGeneralHTML()."\n";
	echo $bookingForm->getVergersHTML()."\n";
	echo $bookingForm->getMusicHTML()."\n";
	echo $bookingForm->getFinanceHTML()."\n";
	echo $bookingForm->getCateringHTML()."\n";
	echo $bookingForm->getPublicityHTML()."\n";
	echo $bookingForm->getTimetableHTML()."\n";
	echo $bookingForm->getSafeguardingHTML()."\n";
	echo $bookingForm->getLiturgyHTML()."\n";
	
	$bookingForm->save();
	

}



?>





